/**********************************************************************************************************
*	© 2010 Autodata Solutions Company. All Rights Reserved
*	This source code is the confidential and proprietary information of Autodata Solutions Company.
*	The user shall not, in whole or in part, copy, publish, disclose or make any use of this source code 
*	without the prior written consent of Autodata Solutions Company.
*
*	Author(s)	: Chris Raposo
*	Purpose		: Add page functionality for compare result
* 	Version		: 1.0
*
* 	Namespace	: 
*********************************************************************************************************/

(function() {
    var EVENTS = net.autodata.EventBus.EVENTS;

    Ext.onReady(function() {
        var session = net.autodata.Session.getInstance();
        var eb = net.autodata.EventBus.getInstance();

        var ptb = new net.autodata.compare.toolbars.PageToolbar({
            viewCfg: { activeKey: 'results' },
            renderTo: 'comparetoppanel-wrap'
        });

        var cvp = new net.autodata.compare.CompareVehiclesPanel({
            plugins: [
			    new net.autodata.compare.plugins.CompareVehiclesEventBus(),
			    new net.autodata.compare.plugins.CompareVehiclesNavigation(),
				new net.autodata.compare.plugins.CompareVehiclesColourPicker()
		    ],

            renderTo: 'comparevehiclepanel-wrap',

            storeCfg: {
                proxy: new net.autodata.compare.data.CompareVehiclesSessionProxy()
            },

            view: new net.autodata.compare.CompareVehiclesView()
        });

        var ds = net.autodata.modelwalk.data.YearMakeModelDataStore.getInstance();
        ds.load();

        var toolbar = new net.autodata.compare.ResultsGridToolbar();

        var grid = new net.autodata.compare.ResultsGrid({
            tbar: toolbar,
            viewCfg: {
                scrollOffset: 0
            },
            plugins: [
                new net.autodata.compare.plugins.ResultGridEventBusConnector(),
                toolbar
            ],
            renderTo: 'comparebottompanel-wrap'
        });

        eb.fireEvent(EVENTS.READY);
    });
})();